package kr.hkit.powerjava.chapter22.work2.Dao;

import java.util.ArrayList;
import java.util.Comparator;

import kr.hkit.powerjava.chapter22.work2.Vo.Department;
import kr.hkit.powerjava.chapter22.work2.Vo.Student;

public class DepartmentMeneger implements ItemDaoInterface<Department> {

	private ArrayList<Department> arList;

	public DepartmentMeneger(ArrayList<Department> arList) {
		this.arList = arList;
	}

	@Override
	public void addItem(Department Item) {
		arList.add(Item);
	}

	@Override
	public void delItem(Department Item) {
		arList.remove(arList.indexOf(Item));
	}

	@Override
	public void updateItem(Department Item) {
		if (searchItem(Item)) {
			arList.set(arList.indexOf(Item), Item);
		} else {
			System.out.println("수정 실패");
		}
	}

	@Override
	public boolean searchItem(Department Item) {
		return arList.contains(Item);
	}

	@Override
	public void prnItem() {
		prnHeader();
		for (Department d : arList) {
			System.out.println(d);
		}
	}

	private void prnHeader() {
		String str = String.format("%s\t %s\t %s\n", "번호", "이름", "층");
		System.out.println(str);
		System.out.println("-------------------");
	}

	@Override
	public void prnItems(Comparator<Student> comp) {

	}

}
